package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"time"
)

type  Person struct {
	//不能为空并且大于10
	Age      int       `form:"age" binding:"required,gt=10"`
	Name     string    `form:"name" binding:"required"`
	Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"`
}

func main() {
	r:= gin.Default()
	r.GET("/51mh", func(c *gin.Context) {
		var Person Person
		if err := c.ShouldBind(&Person);err!=nil {
			c.String(http.StatusInternalServerError, fmt.Sprint(err))
			return
		}
		c.String(http.StatusOK, fmt.Sprintf("%#v", Person))
	})
	r.Run(":8900")

	http.HandleFunc("/", func(w http.ResponseWriter,r2 *http.Request) {
		w.Write([]byte("heelo"))
	})
	if err := http.ListenAndServe(":8080",nil);err!=nil {
		fmt.Println("start",err)
	}

}

